#!/bin/bash
# 
# This is a complete hack. If you're reading this file, you are truly 
# desperate. I pity you. 
#############################################################################

SEP="======================================================================"

echo $SEP
. ./base_functions.sh
. ./gf_functions.sh


# These are the required applications 

applist="curl
         bc
         grep
         md5sum
         xmlwf
         more
        "

echo 
echo ABOUT bashWebTest

more about.txt

echo "

[Hit ENTER to continue to the dependency check. ]
  "
read foo

echo $SEP
echo DEPENDENCY CHECK
echo 
echo "These applications are usually included by default"


for app in $applist; do 

	echo " info: required utility: $app"

	if [ `which $app 2>/dev/null | wc -l` -eq 1 ]; then
		echo " info: $app is available."
		# the --version option is not supported by all the
                # required utilities, so make it's output optional
                # for when debugging is enabled.
		[ "$DEBUG" = "true" ] && $app --version
	else
		echo -e "${red}error: $app is NOT available!${nc}"
		echo "error: need to install and/or add $app to your PATH environment variable. "
	fi

	echo
done 

echo 
echo "Text coloring: (nice to have)"
echo -e "${red} This is red (FAIL)"
echo -e "${yellow} This is yellow (WARN)"
echo -e "${nc} This is no color PASS"


echo $SEP
echo SETUP
echo 

if [ -w results ] ; then
	echo " info: results dir exists and is writable"
	echo
	ls -ld results 
elif [ -d results ]; then
	echo " warn: results dir exists but is not writable"
	chmod +w results
else
	echo " warn: results dir does not exist.  creating."
	mkdir -p results
	chmod +w results
fi

echo "
[Hit ENTER to continue to the available tests.]
  "
read foo


echo $SEP
echo AVAILABLE FUNCTIONAL TESTS
echo

availtests=`ls -c1 test* 2>/dev/null`

for i in $availtests ; do
 	echo $i
 	grep "testdescription=" $i
done ;
 
echo $SEP
echo AVAILABLE HTML VALIDATION TESTS
echo

availtests=`ls -c1 validate* 2>/dev/null`

for i in $availtests ; do
 	echo $i
 	grep "testdescription=" $i
done

echo "
[Hit ENTER to continue to the available functions.]
  "
read foo

echo $SEP
echo AVAILABLE functions
echo 

availtests=`ls -c1 *function* 2>/dev/null`

for i in $availtests ; do
 	echo $i
 	grep "testdescription=" $i
done

echo "
[Hit ENTER to continue to the licensing info. ]
  "
read foo

echo $SEP
echo LICENSING INFO
echo 

more license.txt

echo
echo $SEP
echo "DONE"
echo

exit 0


